import { useEffect, useState } from 'react'
// import { HeaderItem, ProductItem, fetchProductRemAPI } from '@/apis/home'
// import { log } from 'console'
import { Datum, fetchConfigAPI } from '@/apis/config'
function useHome() {
  const [isLoading, setLoading] = useState<boolean>(false)
  // 标题
  const [config, setConfig] = useState<Datum>({})

  useEffect(() => {
    const getConfig = async () => {
      try {
        setLoading(true)
        const res = await fetchConfigAPI()
        // console.log(res);
        setConfig(res.data.data[0])
        setLoading(false)
        // setBanners(res.data.data)
      } catch (error) {
        throw new Error('fetch banners error')
      }
    }
    getConfig()
  }, [])
  // 暴露数据
  return {
    config, isLoading
  }
}

export { useHome }
